import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/* 系统设置 */
// 管理员管理
import Admin from '../views/sys/index'
// 会员信息
import Member from '../views/sys/member'
// 充电桩管理
import Charge from '../views/charge/index'
// 仪器管理
import Instrument from '../views/instrument/index'
// 充电桩检测项目管理
import Project from '../views/project/index'
// 任务工单管理
import Order from '../views/order/index'
// 检测数据管理
import Detection from '../views/detection/index'
import Gd from '../views/detection/gd'
// 检测数据报告管理
import Report from '../views/report/index'

export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    noDropdown: true, // 隐藏一级目录
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'table' }
    }]
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  // 系统模块
  {
    path: '/sys',
    component: Layout,
    redirect: '/sys/member',
    name: '系统设置',
    meta: { title: '系统设置', icon: 'setting', role: [1, 2] },
    children: [
      {
        path: 'index',
        component: Admin,
        name: '管理员管理',
        meta: { title: '管理员管理' }
      },
      {
        path: 'member',
        component: Member,
        name: '会员信息',
        meta: { title: '会员信息' }
      },
      {
        path: 'zw1',
        component: Layout,
        hidden: true,
        meta: { title: '占位' }
      }
    ]
  },
  // 充电桩管理
  {
    path: '/charge',
    component: Layout,
    redirect: '/charge/index',
    meta: { title: '充电桩管理', icon: 'good', role: [1, 2] },
    children: [
      {
        path: 'index',
        component: Charge,
        meta: { title: '充电桩管理' }
      },
      { path: 'zhanwei', component: Layout, hidden: true }
    ]
  },
  // 检测仪器管理
  {
    path: '/instrument',
    component: Layout,
    redirect: '/instrument/index',
    meta: { title: '仪器管理', icon: 'good', role: [1, 2] },
    children: [
      {
        path: 'index',
        component: Instrument,
        meta: { title: '仪器管理' }
      },
      { path: 'zhanwei', component: Layout, hidden: true }
    ]
  },
  // 检测仪器管理
  {
    path: '/project',
    component: Layout,
    redirect: '/project/index',
    meta: { title: '检测项目管理', icon: 'good', role: [1, 2] },
    children: [
      {
        path: 'index',
        component: Project,
        meta: { title: '检测项目管理' }
      },
      { path: 'zhanwei', component: Layout, hidden: true }
    ]
  },
  // 检测仪器管理
  {
    path: '/order',
    component: Layout,
    redirect: '/order/index',
    meta: { title: '任务工单管理', icon: 'good', role: [1, 2] },
    children: [
      {
        path: 'index',
        component: Order,
        meta: { title: '任务工单列表' }
      },
      { path: 'zhanwei', component: Layout, hidden: true }
    ]
  },
  // 检测数据管理
  {
    path: '/detection',
    component: Layout,
    redirect: '/detection/index',
    meta: { title: '检测数据管理', icon: 'good', role: [1, 2] },
    children: [
      {
        path: 'index',
        component: Detection,
        meta: { title: '检测数据列表' }
      },
      {
        path: 'gd',
        component: Gd,
        meta: { title: '图形统计' }
      },
      { path: 'zhanwei', component: Layout, hidden: true }
    ]
  },
  // 检测数据报告管理
  {
    path: '/report',
    component: Layout,
    redirect: '/report/index',
    meta: { title: '检测数据报告', icon: 'good', role: [1, 2] },
    children: [
      {
        path: 'index',
        component: Report,
        meta: { title: '检测报告列表' }
      },
      { path: 'zhanwei', component: Layout, hidden: true }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]
